# 指定构建的基础镜像，版本根据项目需要更换
FROM node:18-alpine AS builder

# 设置工作目录
WORKDIR /app

COPY . .

RUN npm config set registry https://registry.npmmirror.com
# 安装依赖并编译前端代码
RUN npm install && \
    npm run build

# 构建 Nginx 镜像，版本根据项目需要更换
FROM nginx:1.21.3-alpine

# 复制编译后的前端代码到 Nginx 静态资源目录
COPY --from=builder /app/dist /usr/share/nginx/html/vue/

# 复制自定义的 Nginx 配置文件
#COPY ./conf/docker-conpose-default.conf /etc/nginx/conf.d/default.conf

# 暴露端口
EXPOSE 80 

# 启动 Nginx
CMD ["nginx", "-g", "daemon off;"]